package com.yunlankeji.stemcells.adapter;

import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.core.graphics.drawable.RoundedBitmapDrawable;
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;
import androidx.recyclerview.widget.RecyclerView;

import com.yunlankeji.ganxibaozhijia.R;
import com.yunlankeji.stemcells.model.request.Organization_video;

import java.util.List;

public class Fragment_organization_videoAdapter extends RecyclerView.Adapter<Fragment_organization_videoAdapter.Organization_videoViewHolder> {

private List<Organization_video>organization_videoList;

    public Fragment_organization_videoAdapter(List<Organization_video> organization_videoList) {
        this.organization_videoList = organization_videoList;
    }

    @NonNull
    @Override
    public Organization_videoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View itemview = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_organization_video,parent,false);
        Organization_videoViewHolder organization_videoViewHolder = new Organization_videoViewHolder(itemview);
        return organization_videoViewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull Organization_videoViewHolder holder, int position) {
        Organization_video organization_video = organization_videoList.get(position);
        holder.tv_video_title.setText(organization_video.getVideo_title());
        holder.tv_video_organization_name.setText(organization_video.getVideo_organization_name());
        holder.tv_video_organization_fans.setText(organization_video.getVideo_organization_fans());
        holder.iv_organization_video.setImageResource(organization_video.getOrganization_video());
        holder.iv_video_organization_head.setImageResource(organization_video.getVideo_organization_head());

    }

    @Override
    public int getItemCount() {
        return organization_videoList.size();
    }

    class Organization_videoViewHolder extends RecyclerView.ViewHolder {
        TextView tv_video_title;
        TextView tv_video_organization_name;
        TextView tv_video_organization_fans;
        ImageView iv_organization_video;
        ImageView iv_video_organization_head;

        public Organization_videoViewHolder(View itemView) {
            super(itemView);
            this.tv_video_title = itemView.findViewById(R.id.tv_organization_video_introduction);
            this.tv_video_organization_name = itemView.findViewById(R.id.tv_organization_video_name);
            this.tv_video_organization_fans = itemView.findViewById(R.id.tv_organization_video_fans);
            this.iv_organization_video = itemView.findViewById(R.id.iv_organization_video);
            this.iv_video_organization_head = itemView.findViewById(R.id.iv_organization_video_head);
        }
    }
}
